﻿function ShowHidePanel(tbl_em, lnk, stype, cntrl) {

    if (document.getElementById("ctl00_ContentPlaceHolder3_" + lnk) != null) {
        if (document.getElementById("ctl00_ContentPlaceHolder3_" + tbl_em) != null) {
            if (document.getElementById("ctl00_ContentPlaceHolder3_" + tbl_em).style.display == "none") {
                document.getElementById("ctl00_ContentPlaceHolder3_" + tbl_em).style.display = "block";
                if (stype == "CC") {
                    document.getElementById("ctl00_ContentPlaceHolder3_" + lnk).innerHTML = " Remove CC ";
                    if (document.getElementById("ctl00_ContentPlaceHolder3_hfshowCC") != null) {
                        document.getElementById("ctl00_ContentPlaceHolder3_hfshowCC").value = "1";
                    }
                }
                else if (stype == "BCC") {
                    document.getElementById("ctl00_ContentPlaceHolder3_" + lnk).innerHTML = " Remove BCC ";
                    if (document.getElementById("ctl00_ContentPlaceHolder3_hfshowBCC") != null) {
                        document.getElementById("ctl00_ContentPlaceHolder3_hfshowBCC").value = "1";
                    }
                }
                else {
                    if (document.getElementById("ctl00_ContentPlaceHolder3_hfshowAttach") != null) {
                        document.getElementById("ctl00_ContentPlaceHolder3_hfshowAttach").value = "1";
                    }
                }

            }
            else {
                document.getElementById("ctl00_ContentPlaceHolder3_" + tbl_em).style.display = "none";
                if (document.getElementById("ctl00_ContentPlaceHolder3_" + cntrl) != null) {
                    if (document.getElementById("ctl00_ContentPlaceHolder3_" + cntrl).type == "textarea") {
                        document.getElementById("ctl00_ContentPlaceHolder3_" + cntrl).innerHTML = "";
                    }
                    else if (document.getElementById("ctl00_ContentPlaceHolder3_" + cntrl).type == "file") {
                        document.getElementById("ctl00_ContentPlaceHolder3_" + cntrl).value = "";
                    }
                }
                if (stype == "CC") {
                    document.getElementById("ctl00_ContentPlaceHolder3_" + lnk).innerHTML = " Add CC ";
                    if (document.getElementById("ctl00_ContentPlaceHolder3_hfshowCC") != null) {
                        document.getElementById("ctl00_ContentPlaceHolder3_hfshowCC").value = "0";
                    }
                }
                else if (stype == "BCC") {
                    document.getElementById("ctl00_ContentPlaceHolder3_" + lnk).innerHTML = " Add BCC ";
                    if (document.getElementById("ctl00_ContentPlaceHolder3_hfshowBCC") != null) {
                        document.getElementById("ctl00_ContentPlaceHolder3_hfshowBCC").value = "0";
                    }
                }
                else {
                    if (document.getElementById("ctl00_ContentPlaceHolder3_hfshowAttach") != null) {
                        document.getElementById("ctl00_ContentPlaceHolder3_hfshowAttach").value = "0";
                    }

                }
            }
        }
    }

}

function OpenLookup(hiddenfieldid, textboxid, strBindRowID, strPK, pgs_id, MK) {
    searchdata = document.getElementById("ctl00_ContentPlaceHolder3_" + textboxid).value;
    document.getElementById("ctl00_ContentPlaceHolder3_" + textboxid).focus();
    window.open("searchPopUp.aspx?bnd=" + strBindRowID + "&pgs_id=" + pgs_id + "&CnID=" + hiddenfieldid + "&txtCnID=" + textboxid + "&SD=" + searchdata + "&PK=" + strPK + "&typ=EM", null, "toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=800,height=630,left=100,top=30").focus();
}

function UpdateRelatedTo() {
    if (document.getElementById("ctl00_ContentPlaceHolder3_txtTo") != null) {
        if (document.getElementById("ctl00_ContentPlaceHolder3_txtRelatedTo") != null) {
            var text = document.getElementById("ctl00_ContentPlaceHolder3_txtRelatedTo").innerHTML;
            if (text.indexOf(":") > 0) {
                var removetext = text.substring(text.indexOf(":"));
                var textdisplay = ": " + document.getElementById("ctl00_ContentPlaceHolder3_txtTo").value;
                document.getElementById("ctl00_ContentPlaceHolder3_txtRelatedTo").innerHTML = document.getElementById("ctl00_ContentPlaceHolder3_txtRelatedTo").innerHTML.replace(removetext, textdisplay);
            }
        }
    }
}
function ReEnableSendButton() {
    try {
        if (document.getElementById("ctl00_ContentPlaceHolder3_btnSend") != null)
            document.getElementById("ctl00_ContentPlaceHolder3_btnSend").disabled = false;
        if (document.getElementById("ctl00_ContentPlaceHolder3_btnSendTop") != null)
            document.getElementById("ctl00_ContentPlaceHolder3_btnSendTop").disabled = false;

        if (document.getElementById("ctl00_ContentPlaceHolder3_lblmessage") != null)
            if (document.getElementById("ctl00_ContentPlaceHolder3_lblmessage").innerHTML != "") {
                document.getElementById("ctl00_ContentPlaceHolder3_lblmessage").innerHTML = "";
            }

    }
    catch (Ex) {
    }
}